<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <!-- 指定字符集 -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>用户信息管理系统</title>
    <!-- 1. 导入CSS的全局样式 -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <!-- 2. jQuery导入，建议使用1.9以上的版本 -->
    <script src="js/jquery-2.1.0.min.js"></script>
    <!-- 3. 导入bootstrap的js文件 -->
    <!-- <script src="js/bootstrap.min.js"></script>-->
    <style type="text/css">
        td, th {
            text-align: center;
        }
    </style>
</head>
<body>
<div class="container">
    <h3 style="text-align: center;margin-bottom: 50px;">库兔会员管理</h3>
    <div style="float: left;">
        <form class="form-inline">
            <div class="form-group">
                <label for="ipt_name">姓名</label>
                <input name="name" type="text" class="form-control" id="ipt_name">
            </div>
            <div class="form-group">
                <label for="ipt_phone">手机号</label>
                <input name="phone" type="text" class="form-control" id="ipt_phone">
            </div>
            <button id="submit1" type="button" class="btn btn-default" onclick="oncli()">查询</button>
        </form>
    </div>
    <div style="float: right;margin-bottom: 15px">
        <a class="btn btn-primary" href="add.html">添加用户</a>
        <a id="delete" class="btn btn-primary" href="javascript:del()">删除选中</a>
    </div>
    <table border="1" class="table table-bordered table-hover">
        <tr class="success">
            <th>选择</th>
            <th>编号</th>
            <th>姓名</th>
            <th>手机号</th>
            <th>性别</th>
            <th>年龄</th>
            <th>积分</th>
            <th>超管</th>
            <th>操作</th>
        </tr>
        <tbody id="info">
            
        </tbody>
    </table>
    <div>
        <nav aria-label="Page navigation">
            <ul id="all" class="pagination">
                                <li class="active"><a href="javascript:void(0);">1</a></li>
                                <li><a href="javascript:void(0);">2</a></li>
                                <li><a href="javascript:void(0);">3</a></li>
                                <li><a href="javascript:void(0);" aria-label="Next">
                                    <span aria-hidden="true">&raquo;</span></a>
                                </li>
                                <span style="font-size: 20px;margin-left: 10px;"> 共 10 条记录，共 1 页
                                  </span>
            </ul>
        </nav>
    </div>
</div>
<script>
    //获取用户列表
    function getList(){
        jQuery.ajax({
            url:"/user/list",
            type:"GET",
            data:{},
            success:function(result){
                if(result!=null && result.data.length>0){
                    var listDiv="";
                    for(var i = 0;i<result.data.length;i++){
                        var userinfo = result.data[i];
                        listDiv += '<tr>';
                        listDiv += '<th>';
                        listDiv += ' <input id="1" type="checkbox">';
                        listDiv += '</th>';
                        listDiv += '<th>'+userinfo.uid+'</th>';
                        listDiv += '<th>'+userinfo.username+'</th>';
                        listDiv += '<th>'+userinfo.phone+'</th>';
                        listDiv += '<th>'+userinfo.sex+'</th>';
                        listDiv += '<th>'+userinfo.age+'</th>';
                        listDiv += '<th>'+userinfo.point+'</th>';
                        listDiv += '<th>'+(userinfo.isadmin==true?"是":"否")+'</th>';
                        listDiv += '<th>';
                        listDiv += '<a class="btn btn-default btn-sm" href="update.hytml?id='+userinfo.uid+'">修改</a>';
                        listDiv += '<a class="btn btn-default btn-sm" href="javascript:mydel('+userinfo.uid+');">删除</a>';
                        listDiv += ' </th></tr>';
                        
                    }
                    jQuery("#info").html(listDiv);

                }
            }

        });
    }
    getList();

    //删除方法
    function mydel(uid){
        alert(uid);
    }

</script>
</body>

</html>
